package h_Executor;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class Executor_demo1 {
	public static void main(String[] args) {
		Runnable hello = () -> {
			for (int i = 0; i < 100; i++) {
				System.out.println(i+"hello");
				
			}
		};
		Runnable bye =() ->{
			for (int i = 0; i < 100; i++) {
				System.out.println(i+"bye");
			}
		};
		
		Executor executor=Executors.newCachedThreadPool();
		executor.execute(hello);
		executor.execute(bye);
	}
	/**
	 * 上面程序使用了两个Runnable任务hello和bye来打印相应语句，程序将会交错打印hello和bye。
	 * 如果将executor改为SingleThreadExecutor，
	 * 将会先打印100个"hello"，再打印100个"bye"。
	 */
}
